try {
    # 设置API URL
    $apiUrl = "http://localhost:5269/api/file/types"
    
    # 尝试调用API并获取完整响应
    $response = Invoke-WebRequest -Uri $apiUrl -Method Get -ErrorAction Stop
    
    # 输出成功响应
    Write-Host "API调用成功! 状态码: $($response.StatusCode)"
    Write-Host "响应内容:"
    $response.Content | ConvertFrom-Json | ConvertTo-Json -Depth 10
} catch {
    # 输出详细错误信息
    Write-Host "API调用失败!"
    Write-Host "错误类型: $($_.Exception.GetType().FullName)"
    Write-Host "错误消息: $($_.Exception.Message)"
    
    # 尝试获取响应内容（如果有）
    if ($_.Exception.Response) {
        $errorContent = $_.Exception.Response.GetResponseStream()
        $reader = New-Object System.IO.StreamReader($errorContent)
        $errorText = $reader.ReadToEnd()
        Write-Host "响应错误内容: $errorText"
    }
    
    # 输出完整异常堆栈
    Write-Host "完整异常:"
    $_.Exception | Format-List -Force
}